﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace uban.demo.Protocol
{
    public class LoginState
    {
        public short Length { get; private set; }
        public short SteamId { get; private set; }
        public int DevId { get; private set; }
        public short Version { get; private set; }
        public string SerialId { get; private set; }
        public short Crc16 { get; private set; }
        public byte SumCheck { get; private set; }
        public LoginState(byte[] raw)
        {
            /* 解析上线通知 */
            Length = (short)(raw[2] + (raw[3] << 8));
            SteamId = (short)(raw[4] + (raw[5] << 8));
            DevId = raw[8] + (raw[9] << 8) + (raw[10] << 16) + (raw[11] << 24);
            Version = (short)(raw[12] + (raw[13] << 8));
            /* 获取序列号 */
            SerialId = BitConverter.ToString(raw, 14, 12);
            Crc16 = (short)(raw[26] + (raw[27] << 8));
            SumCheck = raw[28];
        }
    }
}
